{extend name="base"/}
{block name="main"}
<div class="Hui-article">
    <article class="cl pd-20">
        <div id="tab_demo" class="HuiTab" style="margin-bottom: 15px; position:relative;">
            <div class="tabBar clearfix">
                <span class="current">轮播图列表</span>
                <div onclick="add_activity_carousel('添加轮播图','__CONF_SITE__admin/group/group_carousel_add','1000','800')"  class="n_tab_add"><i class="Hui-iconfont">&#xe600;</i>添加轮播图</div>
            </div>
        </div>
        <table class="table table-border table-bordered table-hover table-bg">
            <thead>
            <tr>
                <th scope="col" colspan="11">轮播图</th>
            </tr>
            <tr class="text-c">
                <th>排序</th>
                <th>图片</th>
                <th>状态</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            {volist name="list" id="vo"}
            <tr class="text-c">
                <td style="text-align: center;"><input type="text" class="sort input-common" onchange="activity_class_sort('{$vo.id}',this.value)" value="{$vo['sort']}" size="1"></td>
                <td><img src="{$vo['img']}" style="width: 50px;height: 50px;"></td>
                <td>
                    {if $vo['enabled']==1}
                    <a href="javascript:;" onclick="bargain_status('{$vo.id}','off')"><span class="label label-success radius">正常</span></a>
                    {else}
                    <a href="javascript:;" onclick="bargain_status('{$vo.id}','on')"><span class="label label-danger radius">禁用</span></a>
                    {/if}
                </td>
                <td>
                    <a href="javascript:;" onclick="activity_carousel('编辑','__CONF_SITE__admin/group/group_carousel_edit&id={$vo.id}',1000,800)">编辑</a>
                    <a href="javascript:;" onclick="bargain_status('{$vo.id}','del')">删除</a>
                </td>
            </tr>
            {/volist}
            </tbody>
        </table>
    </article>
    <div class="n_page_no">
        {$page}
    </div>
</div>
{/block}
{block name="script"}
<script type="text/javascript">
    /*
     参数解释：
     title	标题
     url		请求的url
     id		需要操作的数据id
     w		弹出层宽度（缺省调默认值）
     h		弹出层高度（缺省调默认值）
     */
    /*活动-状态*/
    function bargain_status(id,key){
        var msg='';
        if(key=='off'){
            msg='确定要禁用吗？';
        }else if(key=='on'){
            msg='确定要启用吗？';
        }
        else if(key=='del'){
            msg='确定要删除吗？';
        }
        layer.confirm(msg,function(){
            //此处请求后台程序
            //后台处理
            $.ajax({
                type : "post",
                url : "{:url('group/group_class_use')}",
                data : {
                    "id" : id,
                    "key":key
                },
                success : function(data) {
                    if (data['code'] > 0) {
                        layer.msg('成功',{icon:1,time:1000},function () {
                            window.location.reload();
                        });
                    }else{
                        layer.msg('失败', {icon: 2, time: 1000});
                    }
                }
            })
        });
    }
    /*幻灯片-添加*/
    function add_activity_carousel(title,url,w,h){
        layer_show(title,url,w,h);
    }
    function activity_class_sort(id,val) {
        $.ajax({
            type : "post",
            url : "{:url('group/group_carousel_sort')}",
            data : {
                "id" : id,
                "val":val
            },
            success : function(data) {
                if (data['code'] > 0) {
                    layer.msg('排序成功',{icon:1,time:1000},function () {
                        window.location.reload();
                    });
                }else{
                    layer.msg('排序失败', {icon: 2, time: 1000});
                }
            }
        })
    }
    /**
     * 编辑
     */
    function activity_carousel(title,url,w,h){
        layer_show(title,url,w,h);
    }
</script>
{/block}